#ifndef DSP2833X_ADCLIB_H_
#define DSP2833X_ADCLIB_H_

//=====================================================
// Define some macros for ADC Modules
//=====================================================

// For initialize
enum ADC_Sequencer_Mode {ADC_DUAL_SEQUENCERS, ADC_CASCADED_SEQUENCER};
enum ADC_Operation_Mode {ADC_START_STOP_MODE, ADC_CONTINUOUS_MODE};
enum ADC_Sampling_Mode 	{ADC_SEQUENTIAL_MODE, ADC_SIMULTANEOUS_MODE};
enum ADC_Override_Mode	{ADC_OVERRIDE_DIS, ADC_OVERRIDE_EN};


enum ADC_SEQUENCER {ADC_SEQ1, ADC_SEQ2, ADC_SEQ};
	// ADC_SEQ1, ADC_SEQ2 for Dual-sequencers
	// ADC_SEQ for cascaded sequencer	
enum ADC_Int_Mode { ADC_INT_EVERY_EOS, ADC_INT_EVERY_OTHER_EOS};

enum ADC_CONV_Number {CONV00, CONV01, CONV02, CONV03, CONV04, CONV05, CONV06, CONV07,
					  CONV08, CONV09, CONV10, CONV11, CONV12, CONV13, CONV14, CONV15};
					  
enum ADC_Status {ADC_IDLE, ADC_BUSY};  
//=====================================================
// Declare some functions
//=====================================================

// Initialize
void ADC_Init(enum ADC_Sequencer_Mode adc_sequencer_mode,enum ADC_Sampling_Mode adc_sampling_mode,
			  enum ADC_Operation_Mode adc_operation_mode,enum ADC_Override_Mode adc_override_mode);			  
void ADC_InitInterrupt(enum ADC_SEQUENCER SEQ, enum ADC_Int_Mode int_mode, PINT Int_Fcn);
void ADC_SelectChannel(enum ADC_CONV_Number CONV_Num, Uint16 adc_input_offset);
void ADC_SetMaxConversion(enum 	ADC_SEQUENCER SEQ, Uint16 val);

void ADC_SelectAllChannel(Uint16 adc_port);
// Start conversion
void ADC_StartConversion(enum 	ADC_SEQUENCER SEQ, Uint16 val);

// Read data
void ADC_Read(enum 	ADC_SEQUENCER SEQ, Uint16 * buffer, Uint16 num_of_channels);

// Utility functions
void ADC_ResetSequencer(enum ADC_SEQUENCER SEQ);
enum ADC_Status ADC_Busy(enum ADC_SEQUENCER SEQ);
void ADC_ClearIntFlags(enum ADC_SEQUENCER SEQ);
void ADC_EnableTriggers(void);
						
#endif /*DSP2833X_ADCLIB_H_*/
